﻿<!DOCTYPE html>
<html>
<head>
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Content/Styles/Site.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/Styles/jpicker-1.1.6.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/Styles/jpicker.css")" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/DataTables-1.8.0/media/css/demo_page.css")" type="text/css"></script>
    <script src="@Url.Content("~/Scripts/DataTables-1.8.0/media/css/demo_table.css")" type="text/css"></script>
    <script src="@Url.Content("~/Scripts/DataTables-1.8.0/media/js/jquery.dataTables.min.js")" type="text/javascript"></script>
    
    <script src="@Url.Content("~/Scripts/MicrosoftAjax.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/MicrosoftMvcAjax.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/MicrosoftMvcValidation.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.colorbox.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-tablesorter.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.form.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.scrollTo-min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.blockUI.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.bestupper.min.js")" type="text/javascript"></script>
    
    <script type="text/javascript">
        $(document).ready(function () {
            var oTable = $("#tableMgmt").dataTable(
                {
                    "bPaginate": true,
                    "bLengthChange": true,
                    "bFilter": true,
                    "bSort": true,
                    "bInfo": true,
                    "bAutoWidth": true
                }
            );
            $("#a_francis").click(function () {
                alert('The French language option is currently under development. Thanks!');
            });
            $("#a_dutch").click(function () {
                alert('The Dutch language option is currently under development. Thanks!');
            });
            $("#a_german").click(function () {
                alert('The German language option is currently under development. Thanks!');
            });
            $("a.loginShow").click(function () {
                $("#loginBox").toggle(300);
            });
            $(".loginHide").click(function () {
                $("#loginBox").toggle(300);
            });
            $("#txt_search").focus(function () {
                //alert('sdffsdfsdf');
                var defaultText = $(this).val();
                //alert(defaultText);
                if (defaultText == "Search...") {
                    $(this).val('');
                }
            });
            /* Handler to Show My Cart */
            $("a.cartShow").click(function () {
                if ($('#prodSelectCart').is(':visible')) {
                    $("#prodSelectCart").toggle(300);
                    return;
                }

                // Get the Cart Items
                $.ajax(
					{
					    type: "GET",
					    url: "/ShoppingCart/GetCart",
					    success: function (result) {
					        //alert(result);
					        if (result != '<li>CART IS EMPTY!</li>')
					            if (result.length > 3) {
					                $('#cartList').empty();
					                $('#cartList').append(result);
					            }
					        $("#prodSelectCart").toggle(300);
					        addRemoveFunctionalityToNewCartItems();
					    },
					    error: function (req, status, error) { alert('Something went wrong getting the cart. Can you please try again?') }
					}
				);
	        });
	        
            /* Handler to Hide My Cart */
	        $("#prodSelectCart a.close").click(function () {
	            $("#prodSelectCart").toggle(300);
	        });

	        /* Handler to begin Checkout Process */
	        $("#btn_checkout").click(function () {
	            // Get shopping Cart
	        });

	        $('#opts').change(function () { });

	        $('#a_feedback').click(function () {
	            $.blockUI({
	                message: $('#customer_feedback')
	            });
	        });

	        $('#a_shoppingcart').click(function () {
	            $.blockUI({
	                message: $('#shopping_cart_new')
	            });

	            // Get the Cart Items
	            $.ajax(
					{
					    type: "GET",
					    url: "/ShoppingCart/GetCart",
					    success: function (result) {
					        //alert(result);
					        if (result != '<li>CART IS EMPTY!</li>')
					            if (result.length > 3) {
					                $('#cartList').empty();
					                $('#cartList').append(result);
					            }
					        //$("#prodSelectCart").toggle(300);
					        addRemoveFunctionalityToNewCartItems();
					    },
					    error: function (req, status, error) { alert('Something went wrong getting the cart. Can you please try again?') }
					}
				);
	        });

	        $('#a_closeFeedback,#a_closeShoppingCart').click(function () {
	            $.unblockUI();
	        });

	        $('#btn_sendFeedback').click(function () {
	            var email = $('#txt_femail').val();
	            var subject = $('#txt_fsubject').val();
	            var comment = $('#txt_fcomment').val();

	            //alert(email + '\n' + subject + '\n' + comment);
	            var fdata = 'email=' + email + '&subject=' + subject + '&comment=' + comment;
	            $.ajax(
					{
					    type: "POST",
					    url: "/Utils/SendFeedback",
					    data: fdata,
					    success: function (result) {
					        alert('Feedback sent');
					        $.unblockUI();
					    },
					    error: function (req, status, error) { alert('Something went wrong getting the cart. Can you please try again?') }
					}
				);
	        });
});

        /* Remove ITEM from Cart */
        function addRemoveFunctionalityToNewCartItems() {
            $("a.remove").click(function () {
                var itemToRemove = $(this).parent('li').text();
                var thisLength = itemToRemove.length;
                itemToRemove = itemToRemove.substring(0, thisLength - 1);

                $(this).parent("li").fadeOut("normal", function () {
                    // Remove the Cart Item
                    $.ajax(
						        {
						            type: "POST",
						            data: "newCartEntry=" + itemToRemove,
						            url: "/ShoppingCart/RemoveItemFromCart",
						            success: function (result) {

						                $(this).remove();

						            },
						            error: function (req, status, error) { alert('Something went wrong getting the cart. Can you please try again?') }
						        }
					        );
                });
            });
		}

		/* Add ITEM to Cart */
		function addToCart(val, key) {
		    $.ajax(
				{
				    type: "POST",
				    url: "/ShoppingCart/AddItemToCart",
				    data: "newCartEntry=" + val + "&newCartToken=" + key,
				    success: function (result) {
				        // Get the Cart Items
				        $.ajax(
							{
							    type: "GET",
							    url: "/ShoppingCart/GetCart",
							    success: function (result) {
							        //alert(result);
							        if (result != '<li>CART IS EMPTY!</li>')
							            if (result.length > 3) {
							                $('#cartList').empty();
							                $('#cartList').append(result);
							            }
							        //$("#prodSelectCart").toggle(300);
							        $.blockUI({
							            message: $('#shopping_cart_new')
							        });
							        addRemoveFunctionalityToNewCartItems();
							    },
							    error: function (req, status, error) { alert('Something went wrong getting the cart. Can you please try again?') }
							}
						);
				    },
				    error: function (req, status, error) { alert('Something went wrong. Can you try again?'); }
				}
			);
        }

        /* Save the Final Cart */
        function saveFinalCart(values) {
            $.ajax(
				        {
				            type: "POST",
				            url: "/Cart/SaveFinalCart",
				            data: "values=" + aReturn,
				            success: function (result) { alert(result); },
				            error: function (req, status, error) { alert('Something went wrong. Can you try again?'); }
				        }
			        );

        }

        /* Cookie Handler */
        function getCookie(c_name) {
            var i, x, y, ARRcookies = document.cookie.split(";");
            for (i = 0; i < ARRcookies.length; i++) {
                x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
                y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
                x = x.replace(/^\s+|\s+$/g, "");
                if (x == c_name) {
                    return unescape(y);
                }
            }
        }
    </script>

    <style type="text/css">
	    
		/* Z-index of #mask must lower than #boxes .window */
		#mask {
		  position:absolute;
		  z-index:9000;
		  background-color:#000;
		  display:none;
		  top: 0;
		  left: 0;
		}
   
		#boxes .window {
		  position:absolute;
		  width:540px;
		  height:350px;
		  display:none;
		  z-index:9999;
		  padding:20px; 
		  
		}
 
		/* Customize your modal window here, you can add background image too */
		#boxes #dialog {
		  width:575px;
		  height:450px;
		  background-color:#fff;
		}
		
		.theme
		{
			background-color:#ff0000;
		}
	</style>
</head>
<body>
    <div id="mainContainer">
        <div id="topBar">
            
            @if (_PLATFORM.DATA.Custom_Classes.User.SeedIdentified == false)
            { 
                <div id="logo">
					
				</div>
            }
            else
            {

                var imageName = ViewBag.Logo;
                var path = Url.Content("~/Assets/UserTemplateLogos/" + imageName);
                var imageText = ViewBag.LogoAltText;
                   
                <div id="resellerLogo">
				    <table>
					    <tr>
						    <td valign="center">
						        <img src="@path" alt="@imageText" />
						    </td>
					    </tr>
				    </table>
				</div>
            }
                
            <div class="upperright">
                <div id="languageSelect">
                    <a href="#" class="select" id="a_english">English</a> &nbsp;|&nbsp;
				    <a href="#" id="a_francis">Francis</a> &nbsp;|&nbsp;
				    <a href="#" id="a_dutch">Dutch</a> &nbsp;|&nbsp;
				    <a href="#" id="a_german">German</a>
                    <br style="clear:both;" />
				    <br style="clear:both;" />
                </div>
                <div class="search">
					<span>
						<input type="text" value="Search..." id="txt_search" name="txt_search" style="float: left;" />
						<input type="submit" value="Go!" class="button default btnSmall" style="float: left;" />
					</span>
			    </div>
            </div>
            @*<div id="logindisplay">
                
            </div>*@
            
        </div>
        
        <div id="topNav">
            <ul>
                <li>@Html.ActionLink("Home", "Index", "Home")</li>
                <li>@Html.ActionLink("Build a System", "Index", "Home")</li>
                <li>@Html.ActionLink("Components & Spareparts", "Index", "Home")</li>
            </ul>
                @if (Request.IsAuthenticated)
                {
                    if (User.IsInRole("Administrator") || User.IsInRole("Reseller"))
                    { 
                        <ul>   
                            <li>@Html.ActionLink("FT", "Index", "FittingType")</li>
                            <li>@Html.ActionLink("FTA", 
                            "Index", "FittingTypeAsset")</li>
                            <li>@Html.ActionLink("S", "Index", "Supplier")</li>
                            <li>@Html.ActionLink("C", "Index", "Component", new { productType = "Component" }, null)</li>
                            <li>@Html.ActionLink("CSO", "Index", "SelectionOption", new { productType = "Component" }, null)</li>
                            <li>@Html.ActionLink("SP", "Index", "Component", new { productType = "Sparepart" }, null)</li>
                            <li>@Html.ActionLink("SPO", "Index", "SelectionOption", new { productType = "Sparepart" }, null)</li>
                            <li>@Html.ActionLink("PG", "Index", "Group")</li>
                            <li>@Html.ActionLink("SY", "Index", "Systems")</li>
                            <li>@Html.ActionLink("SFTA", "Index", "SystemFittingTypeAsset")</li>
                            <li>@Html.ActionLink("SP", "Index", "SystemProduct")</li>
                        </ul>
                    }
                    
				    <ul style="float:right;">

					    <li style="float: left;" id="Li2" class="login"><a href="#" id="a_shoppingcart" onclick="return false;">My Cart</a></li>
					    <li style="float: left;" class="login">@Html.ActionLink("My Account", "MyAccount", "User", null, new { @class = "loginShow" })</li>
					    <li style="float: left;" class="login">@Html.ActionLink("Log Out", "LogOff", "Account", null, new { @class = "logout" })</li>
				    </ul>
                }
                else
                { 
                    <ul>
                        <li class="login" id="Li1"><a href="#" class="loginShow" onclick="return false;">My Account</a></li>
                        <div id="loginBox">
					        <div class="loginLock">
						        <img src="../../Assets/images/login_lock2.png" /><h2>My Account</h2><br />
					        </div>
                                @Html.Partial("_LogOnPartial_2")
						        <a href="#" class="loginHide" onclick="return false;" style="color: #fff; margin: 7px 0 0 0; display: block; font-weight: normal; font-size: 11px;">Close</a>
                                @*@Html.Partial("_LogOnPartial")*@
				        </div> 
                    </ul>
                }
            
            
        </div>
        <div id="main">
            @RenderBody()
        </div>
        
        <div id="growlUI_home" style="display:none; background:null no-repeat 10px 10px;">
		    <img src="../../Assets/images/check48.png" />
		    <h2 style="color: white; padding: 5px 5px 5px 75px; text-align: left;">Check your cart anytime!</h2>
		
	    </div>
	
	    <div id="customer_feedback" style="display:none;">
		    <span style="float:right;"><a href="#" id="a_closeFeedback" class="close" onclick="return false;">close</a></span>
		    <table class="feedback">
			    <tr>
				    <td colspan="2" class="title">
				    User Feedback
				    </td>
			    </tr>
			    <tr>
				    <td>
					    <b>Email:</b>
				    </td>
				    <td>
					    <input id="txt_femail" type="text" />
				    </td>
			    </tr>
			    <tr>
				    <td>
					    <b>Subject:</b>
				    </td>
				    <td>
					    <input id="txt_fsubject" type="text" />
				    </td>
			    </tr>
			    <tr>
				    <td>
					    <b>Comment:</b>
				    </td>
				    <td>
					    <textarea id="txt_fcomment"></textarea>
				    </td>
			    </tr>
			    <tr>
				    <td colspan="2">
				    <input type="submit" id="btn_sendFeedback" class="button default btnLarge" value="Send Feedback" /><br /><br />
				    </td>
			    </tr>
		    </table>
	    </div>
	
	
	    <div id="shopping_cart_new" style="display:none;">
		    <span style="float:right;"><a href="#" id="a_closeShoppingCart" class="close" onclick="return false;">close</a></span>
		    <table class="feedback">
			    <tr>
				    <td colspan="2" class="title">
				    Shopping Cart
				    </td>
			    </tr>
			    <tr>
				    <td>
					    <div id="prodSelectCart">
							
							    <div class="inner">
							
								    <ul id="cartList">
								    </ul>
							
							    </div>
					
							    <br /><br />
									
					     </div>
				    </td>
			    </tr>
		    </table>
	    </div>
	
	    <br />
	    <br />
	
	    <div id="footer">
		    <center>Copyright &copy; 2012 Added-TTC, B.V. | <a href="#" id="a_feedback" onclick="return false;">Send Feedback</a></center>
	    </div>
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            var cookieColor = getCookie('NavColor');
            document.getElementById('topNav').style.backgroundColor = cookieColor;
            var accentColor = getCookie('AccentColor');
            $('.default').removeClass('default').css('background-Color', accentColor); //.addClass('theme');
            //$('#topNav').css('backgroundColor', cookieColor);
            $('#loginBox').css('background', cookieColor);
            //alert("1: " + cookieColor);
        });
	</script>
</body>
</html>
